<template>
  <a-modal
    :title="title"
    :width="1000"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    :class="editType =='detail'?'pic-preview':''"
    :cancelText="editType =='detail'?'关闭':'取消'">
    
    <a-spin :spinning="confirmLoading">
      <a-form :form="form" class='prosonal'>
        <a-row>
          <a-col :span="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="姓名">
              <a-input @blur="findCode" :disabled="editType=='detail'" placeholder="请输入姓名" v-decorator="['PersonalName', validatorRules.personalname]" />
            </a-form-item>
          </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="性别">
          <a-select :disabled="editType=='detail'" placeholder="请输入性别" v-decorator="['GenderId', validatorRules.genderid]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option value="3">男性</a-select-option>
            <a-select-option value="4">女性</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="年龄段">
          <a-select :disabled="editType=='detail'" placeholder="请输入年龄段" v-decorator="['AgeGroupId', validatorRules.agegroupid]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.id" v-for="(item,index) in ageGroupData">{{item.name}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="籍贯（省）">
          <a-select show-search :filter-option="filterOption" @change="getCity" :disabled="editType=='detail'" placeholder="请输入籍贯（省）" v-decorator="['ProvinceId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in provinceData">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="籍贯（市）">
          <a-select show-search :filter-option="filterOption" @change="getArea" :disabled="editType=='detail'" placeholder="请选择籍贯（市）" v-decorator="['CityId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in cityData">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="籍贯（区/县）">
          <a-select show-search :filter-option="filterOption" :disabled="editType=='detail'" placeholder="请输入籍贯（区/县）" v-decorator="['DistrictId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in areaData">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="手机">
          <a-input :disabled="editType=='detail'" placeholder="请输入手机" v-decorator="['Phone', {}]" />
        </a-form-item>
        </a-col>
          
          <!-- <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="电话">
          <a-input :disabled="editType=='detail'" placeholder="请输入电话" v-decorator="['Tel', {}]" />
        </a-form-item>
        </a-col> -->
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="微信号">
          <a-input :disabled="editType=='detail'" placeholder="请输入微信号" v-decorator="['Wechat', {}]" />
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="邮箱">
          <a-input :disabled="editType=='detail'" placeholder="请输入邮箱" v-decorator="['Email', {}]" />
        </a-form-item>
        </a-col>
          <!-- <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="Linker">
          <a-select :disabled="editType=='detail'" placeholder="请输入Linker" v-decorator="['LinkerId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.Id" v-for="(item,index) in personData">{{item.Name}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col> -->
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="毕业院校">
          <a-select mode="tags" :disabled="editType=='detail'" placeholder="请输入学历标签" v-decorator="['SchoolDegreeId', {}]" >
            <a-select-option :key="item.BaseInfoId" :value="item.Value" v-for="(item,index) in schoolDegreeData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="职业标签">
          <a-select mode="tags" :disabled="editType=='detail'" placeholder="请输入工作标签" v-decorator="['JobProfessionalId', {}]" >
            <a-select-option :key="item.BaseInfoId" :value="item.Value" v-for="(item,index) in jobProfessionalData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="个人标签">
          <a-select mode="tags" :disabled="editType=='detail'" placeholder="请输入个人荣誉" v-decorator="['PersonalHonorId', {}]" >
            <a-select-option :key="item.BaseInfoId" :value="item.Value" v-for="(item,index) in personalHonorData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <!-- <hr style="clear:both;border:none"/>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="个人爱好">
          <a-select mode="tags" :disabled="editType=='detail'" placeholder="请输入个人爱好" v-decorator="['PersonalHobbiesId', {}]" >
            <a-select-option :key="item.BaseInfoId" :value="item.Value" v-for="(item,index) in personalHobbiesData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col> -->

        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="个人简介">
          <a-input type="textarea" :disabled="editType=='detail'" placeholder="请输入个人简介" v-decorator="['PersonalBrief', {}]" />
        </a-form-item>
        </a-col>
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="个人名片1">
          <a-input v-show v-decorator="['BusinessCard', {}]" />
          <a-upload
            name="file"
            :multiple="false"
            :accept="accept"
            :showUploadList="false"

            v-decorator="['FilesName', {}]"
            :beforeUpload="uploadPic">
            <a-button><a-icon type="upload"/>上传</a-button>
          </a-upload>
          <span style="margin-left:10px;">
            <template v-for="(item,index) in fileList">
              <img @click="picUrl = 'https://link.zhangtongshe.com'+item.url,showPic=true" style="width:80px;cursor: pointer;" :src="'https://link.zhangtongshe.com'+item.url">
              <a-icon style="cursor:pointer;margin-left:10px;" type="delete" @click="deleteFileObj(index)"/>
            </template>
            
          </span>
        </a-form-item>
        </a-col>
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="个人名片2">
          <a-input v-show v-decorator="['BusinessCard2', {}]" />
          <a-upload
            name="file"
            :multiple="false"
            :accept="accept"
            :showUploadList="false"

            v-decorator="['FilesName2', {}]"
            :beforeUpload="uploadPic2">
            <a-button><a-icon type="upload"/>上传</a-button>
          </a-upload>
          <span style="margin-left:10px;">
            <template v-for="(item,index) in fileList2">
              <img @click="picUrl = 'https://link.zhangtongshe.com'+item.url,showPic=true" style="width:80px;cursor: pointer;" :src="'https://link.zhangtongshe.com'+item.url">
              <a-icon style="cursor:pointer;margin-left:10px;" type="delete" @click="deleteFileObj2(index)"/>
            </template>
            
          </span>
        </a-form-item>
        </a-col>
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="个人名片3">
          <a-input v-show v-decorator="['BusinessCard3', {}]" />
          <a-upload
            name="file"
            :multiple="false"
            :accept="accept"
            :showUploadList="false"

            v-decorator="['FilesName3', {}]"
            :beforeUpload="uploadPic3">
            <a-button><a-icon type="upload"/>上传</a-button>
          </a-upload>
          <span style="margin-left:10px;">
            <template v-for="(item,index) in fileList3">
              <img @click="picUrl = 'https://link.zhangtongshe.com'+item.url,showPic=true" style="width:80px;cursor: pointer;" :src="'https://link.zhangtongshe.com'+item.url">
              <a-icon style="cursor:pointer;margin-left:10px;" type="delete" @click="deleteFileObj3(index)"/>
            </template>
            
          </span>
        </a-form-item>
        </a-col>
          <!-- <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="互动标签">
          <a-input :disabled="editType=='detail'" placeholder="请输入互动标签" v-decorator="['InteractiveTagId', {}]" />
        </a-form-item>
        </a-col> -->
		  </a-row>
      </a-form>
    </a-spin>
    <a-modal :width="600" :visible="showPic" @cancel="showPic = false" class="pic-preview" title="查看大图">
      <img :src="picUrl" style="width:100%"/>
    </a-modal>
    <commonModal
      modalTitle="标签选择"
      rowKey="BaseInfoId"
      ref="commonModalUser"
      @getCommonModalData="commonModalDataUser"
      :columns="baseInfoColumn"
      apiUrl="/baseInfo/queryRows"
      :conditions="hornorContions"
      :searchArr="searchArrBaseInfo"></commonModal>
  </a-modal>
</template>

<script>
  import { httpAction,postAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"
  import commonModal from '@/components/commonModal'
  export default {
    name: "PersonalInfoModal",
    components:{
      commonModal
    },
    watch:{
      visible(newVal,oldVal){
        if(newVal){
          this.editType = sessionStorage.getItem('editType');
        }
      }
    },
    data () {
      return {
        showPic: false,
        accept: 'image/*',
        fileList:[],
        fileList2:[],
        fileList3:[],
        hornorContions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'PersonalHonor'
            }],
        baseInfoColumn:[
          { title: '名称', dataIndex: 'Value' },
          { title: '更新人', dataIndex: 'UpdateBy_Name' }
        ],
        searchArrBaseInfo:[
          { label: '名称', key: 'Value' },
        ],
        personData:[],
        ageGroupData:[{
          id:'116',
          name:'40后'
        },{
          id:'117',
          name:'50后'
        },{
          id:'118',
          name:'60后'
        },{
          id:'119',
          name:'70后'
        },{
          id:'120',
          name:'80后'
        },{
          id:'121',
          name:'90后'
        },{
          id:'122',
          name:'00后'
        },{
          id:'123',
          name:'10后'
        }],
        jobProfessionalData:[],
        personalHobbiesData:[],
        schoolDegreeData:[{
          id:'124',
          name:'博士'
        },{
          id:'125',
          name:'教授'
        },{
          id:'126',
          name:'复旦系'
        },{
          id:'127',
          name:'交大系'
        },{
          id:'128',
          name:'清华系'
        },{
          id:'129',
          name:'北大系'
        }],
        personalHonorData:[{
          id:'130',
          name:'工程院院士'
        },{
          id:'131',
          name:'科学院院士'
        },{
          id:'132',
          name:'国家千人'
        },{
          id:'133',
          name:'浦东新区百人计划'
        },{
          id:'134',
          name:'国家杰出青年'
        }],
        editType:'',
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 },
        },
        labelColMax: {
          xs: { span: 24 },
          sm: { span: 4 },
        },
        wrapperColMax: {
          xs: { span: 24 },
          sm: { span: 19 },
        },
        areaData:[],
        cityData:[],
        provinceData:[],
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        personalinfoid:{rules: [{ required: true, message: '请输入个人信息ID!' }]},
        personalname:{rules: [{ required: true, message: '请输入姓名!' }]},
        genderid:{rules: [{ required: true, message: '请输入性别!' }]},
        provinceid:{rules: [{ required: true, message: '请输入籍贯省!' }]},
        cityid:{rules: [{ required: true, message: '请输入籍贯市!' }]},
        districtid:{rules: [{ required: true, message: '请输入籍贯区/县!' }]},
        phone:{rules: [{ required: true, message: '请输入手机!' }]},
        tel:{rules: [{ required: true, message: '请输入电话!' }]},
        wechat:{rules: [{ required: true, message: '请输入微信!' }]},
        email:{rules: [{ required: true, message: '请输入邮箱!' }]},
        agegroupid:{rules: [{ required: true, message: '请输入年龄段!' }]},
        schooldegreeid:{rules: [{ required: true, message: '请输入学校/学历!' }]},
        jobprofessionalid:{rules: [{ required: true, message: '请输入工作/专业!' }]},
        personalhonorid:{rules: [{ required: true, message: '请输入个人荣誉!' }]},
        personalhobbiesid:{rules: [{ required: true, message: '请输入个人爱好!' }]},
        interactivetagid:{rules: [{ required: true, message: '请输入互动标签!' }]},
        // linkerid:{rules: [{ required: true, message: '请输入Linker!' }]},
        updatebyid:{rules: [{ required: true, message: '请输入最近更新人!' }]},
        ts:{rules: [{ required: true, message: '请输入最近更新日期!' }]},
        datastatus:{rules: [{ required: true, message: '请输入状态!' }]},
        },
        url: {
          add: "/personalInfo/add",
          edit: "/personalInfo/update",
          baseList:"/baseInfo/queryRows",
          baseAdd:"/baseInfo/add",
          updateFile:"/oss/upload"
        },
      }
    },
    created () {
      this.getPerson();
      this.getProvince();
      this.getBaseData();
    },
    methods: {
      deleteFileObj(index){
        this.fileList = [];
        this.form.setFieldsValue({
            BusinessCard: '',
        })
      },
      uploadPic(fileArr){
        if(!this.url.updateFile){
          return false;
        }
        let httpurl = this.url.updateFile;
        let formData = new FormData();
        // for(let i=0;i<fileArr.length;i++){
        //   formData.append('file',fileArr[i])
        // }
        formData.append('file',fileArr)
        let that = this;
        this.fileList = [];
        that.form.setFieldsValue({
            BusinessCard: '',
        })
        this.$http.postAction(httpurl,formData).then((res)=>{
          if(res.name){
            that.$message.success('上传成功');
            that.form.setFieldsValue({
                BusinessCard: JSON.stringify(res),
            })
            this.fileList.push({url:res.downloadUrl})
            console.log('ssss',this.fileList)
          }else{
            that.$message.warning(res.message);
          }
        })
      },
      deleteFileObj2(index){
        this.fileList2 = [];
        this.form.setFieldsValue({
            BusinessCard2: '',
        })
      },
      uploadPic2(fileArr){
        if(!this.url.updateFile){
          return false;
        }
        let httpurl = this.url.updateFile;
        let formData = new FormData();
        // for(let i=0;i<fileArr.length;i++){
        //   formData.append('file',fileArr[i])
        // }
        formData.append('file',fileArr)
        let that = this;
        this.fileList2 = [];
        that.form.setFieldsValue({
            BusinessCard2: '',
        })
        this.$http.postAction(httpurl,formData).then((res)=>{
          if(res.name){
            that.$message.success('上传成功');
            that.form.setFieldsValue({
                BusinessCard2: JSON.stringify(res),
            })
            this.fileList2.push({url:res.downloadUrl})
            console.log('ssss',this.fileList)
          }else{
            that.$message.warning(res.message);
          }
        })
      },
      deleteFileObj3(index){
        this.fileList3 = [];
        this.form.setFieldsValue({
            BusinessCard3: '',
        })
      },
      uploadPic3(fileArr){
        if(!this.url.updateFile){
          return false;
        }
        let httpurl = this.url.updateFile;
        let formData = new FormData();
        // for(let i=0;i<fileArr.length;i++){
        //   formData.append('file',fileArr[i])
        // }
        formData.append('file',fileArr)
        let that = this;
        this.fileList3 = [];
        that.form.setFieldsValue({
            BusinessCard3: '',
        })
        this.$http.postAction(httpurl,formData).then((res)=>{
          if(res.name){
            that.$message.success('上传成功');
            that.form.setFieldsValue({
                BusinessCard3: JSON.stringify(res),
            })
            this.fileList3.push({url:res.downloadUrl})
            console.log('ssss',this.fileList)
          }else{
            that.$message.warning(res.message);
          }
        })
      },
      findCode(){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let arr = [];
          if(data.PersonalName){
            arr.push({"field":"PersonalName",
              "operator":"=",
              "value":data.PersonalName
            });
          }
          this.$http.postAction('/personalInfo/queryRows',{pageNo:1,pageSize:1,selectFields:[],conditions:{OR:arr}}).then(res=>{
              if(res.status == 1 && 0 < res.data.rows.length){
                if(res.data.rows[0].PersonalInfoId == this.model.PersonalInfoId){
                  return
                }
                this.$message.warning('系统已存在次人员，继续新增将会产生一条新的人员记录');
              }
            })
        })
        
      },
      filterOption(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      getBaseData(){
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'SchoolDegree'
            }]}).then((res)=>{
          if(res.status == 1){
            this.schoolDegreeData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'PersonalHonor'
            }]}).then((res)=>{
          if(res.status == 1){
            this.personalHonorData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'jobProfessional'
            }]}).then((res)=>{
          if(res.status == 1){
            this.jobProfessionalData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'personalHobbies'
            }]}).then((res)=>{
          if(res.status == 1){
            this.personalHobbiesData = res.data.rows;
          }
        })
      },
      addBase(data){
        let copyData = JSON.parse(JSON.stringify(data));
        let arr = [];
        if(copyData.SchoolDegreeId){
          copyData.SchoolDegreeId.split(',').forEach((e)=>{
            if(!this.schoolDegreeData.some((item)=>{return item.Value == e})){
              arr.push({
                TypeCode:'SchoolDegree',
                TypeName:'毕业院校',
                Value:e
              })
            }
          })
        }
        if(copyData.PersonalHonorId){
          copyData.PersonalHonorId.split(',').forEach((e)=>{
            if(!this.personalHonorData.some((item)=>{return item.Value == e})){
              arr.push({
                TypeCode:'PersonalHonor',
                TypeName:'个人标签',
                Value:e
              })
            }
          })
        }
        if(copyData.JobProfessionalId){
          copyData.JobProfessionalId.split(',').forEach((e)=>{
            if(!this.jobProfessionalData.some((item)=>{return item.Value == e})){
              arr.push({
                TypeCode:'JobProfessional',
                TypeName:'职业标签',
                Value:e
              })
            }
          })
        }
        if(copyData.PersonalHobbiesId){
          copyData.PersonalHobbiesId.split(',').forEach((e)=>{
            if(!this.personalHobbiesData.some((item)=>{return item.Value == e})){
              arr.push({
                TypeCode:'PersonalHobbies',
                TypeName:'个人爱好',
                Value:e
              })
            }
          })
        }
        console.log('addBaseData',arr)
        arr.forEach((e)=>{
          this.$http.postAction(this.url.baseAdd,e).then((res)=>{
            
          })
        })
      },
      getPerson(){
        this.$http.postAction('/user/queryRows',{pageNo:1,pageSize:9999,conditions:[{
              "field":"WorkStatus",
              "operator":"=",
              "value":'78'
            }]}).then((res)=>{
          if(res.status == 1){
            this.personData = res.data.rows;
          }
        })
      },
      getArea(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              DistrictId:''
            })
          }
          
          this.areaData = [];
          let provinceid = data.CityId;
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"Parent",
              "operator":"=",
              "value":provinceid
            }]}).then(res=>{
            if(res.status == 1){
              this.areaData = res.data.rows;
            }
          })
        })
      },
      getCity(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              CityId:'',
              DistrictId:''
            })
          }
          
          this.cityData = [];
          let provinceid = data.ProvinceId;
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"Parent",
              "operator":"=",
              "value":provinceid
            }]}).then(res=>{
            if(res.status == 1){
              this.cityData = res.data.rows;
              if(type == 'init'){
                this.getArea('init')
              }
            }
          })
        })
      },
      getProvince(){
        this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"RegionType",
              "operator":"=",
              "value":1
            }]}).then(res=>{
          if(res.status == 1){
            this.provinceData = res.data.rows;
          }
        })
      },
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.model.GenderId = this.model.Gender;
        this.model.AgeGroupId = this.model.AgeGroup;
        this.model.ProvinceId = this.model.Province;
        this.model.CityId = this.model.City;
        this.model.DistrictId = this.model.District;
        this.model.LinkerId = this.model.Linker;
        this.model.SchoolDegreeId = this.model.SchoolDegree?this.model.SchoolDegree.split(','):[];
        this.model.JobProfessionalId = this.model.JobProfessional?this.model.JobProfessional.split(','):[];
        this.model.PersonalHonorId = this.model.PersonalHonor?this.model.PersonalHonor.split(','):[];
        this.model.PersonalHobbiesId = this.model.PersonalHobbies?this.model.PersonalHobbies.split(','):[];
        this.fileList = []
        if(this.model.BusinessCard){
          this.fileList.push({url:JSON.parse(this.model.BusinessCard).downloadUrl})
        }
        this.fileList2 = []
        if(this.model.BusinessCard2){
          this.fileList2.push({url:JSON.parse(this.model.BusinessCard2).downloadUrl})
        }
        this.fileList3 = []
        if(this.model.BusinessCard3){
          this.fileList3.push({url:JSON.parse(this.model.BusinessCard3).downloadUrl})
        }
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'PersonalName','GenderId','ProvinceId','CityId','DistrictId','Phone','Tel','Wechat','Email','AgeGroupId','SchoolDegreeId','JobProfessionalId','PersonalHonorId','PersonalHobbiesId','InteractiveTagId','LinkerId','PersonalBrief', 'BusinessCard', 'BusinessCard2', 'BusinessCard3'))
    		  //时间格式化
          this.getCity('init');
        });

      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.PersonalInfoId){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化
            formData.SchoolDegreeId = formData.SchoolDegreeId instanceof Array?formData.SchoolDegreeId.join():formData.SchoolDegreeId;
            formData.JobProfessionalId = formData.JobProfessionalId instanceof Array?formData.JobProfessionalId.join():formData.JobProfessionalId;
            formData.PersonalHonorId = formData.PersonalHonorId instanceof Array?formData.PersonalHonorId.join():formData.PersonalHonorId;
            formData.PersonalHobbiesId = formData.PersonalHobbiesId instanceof Array?formData.PersonalHobbiesId.join():formData.PersonalHobbiesId;
            console.log(formData)
            this.$http.postAction(httpurl,formData).then((res)=>{
              if(res.status == 1){
                that.$message.success('提交成功');
                this.addBase(formData);
                if(method == 'post'){
                  this.form.resetFields();
                  this.model = {};
                }else{
                  that.close();
                }
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              // that.close();
            })



          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style>
  .labelColMax .ant-form-item-label{
    width: 120px;
    float: left;
  }
  .labelColMax .ant-form-item-control-wrapper{
    width: calc(100% - 133px);
    display: inline-block;
  }
</style>